this is much harder than counting