improved hashing algorithm