updated and improved the hashing function