the WORKING version for flips