Rearranged code for readability