refactored hash_directory