refactored number generation