fixed flipping issue