improved comments, shifted code