speedup from reversing loop