reimplemented flipping