reimpl zigzag conversion