updated for rotation and flips