improved flipping