refactored directory.rb and added exit