fix direction detection