Reorder code for readability