put sort back, optimised this time