major sorting rework