Flip code (both directions working)