refactored Formatting.format function