streamlined the logic for the number determining routine.