implemented y-flipping