fixed all errors in the hash function