Rearranged the code for better understanding