Zigzag algorithm added