Added comments and rearranget methods