Added comments, shortened code