Modified directory.rb to use hashes and keys