Refactored code to support different formatting