fix for flipping rows