refactored dir_hash