Updated
Rearranged the code.