Improve hashing algorithm