Reorder code for clarity