cleaning up and sorting