Added comments and rearranged functions