speedup a bit almost sorted