refactored number converter