Even better refactoring of directory.rb