re-written code of original directory.rb file