fix flip bug