Improved directory.rb after Exercise 2