solved direction-flip bug