code refactor

-use prototype pattern instead of returning an object literal.\n-refactor the method which gets direction into a functional approach. less code duplication.