Refactor printing number functionality.