refactored printf