fix regression with gate flipping