Refactoring hash functions