fixed flip bug