little speedup by avoid calculation of middle pos