refactored directions code to Directions.js