breaking out flipflop into a two-part process