Fixed and Simplified getDirection