fixed flipping bugs