Fixed sort, removed unneccesary variables