Fix flip bug