fix bug in filling out zigzag with motion code