improved checking for direction