Rearranges code for performance