Added direction detection