Rearranged code + fixed comment formatting