Updated the toHash function