added flip_state