Fixed bug in flip and reverse