format functionality and break into distinct methods