fix the code of clearDirection