cleaned up some sorting