Refactoring of the Hasher function.