sorting ATG but error when adding due to nil class