Updated hash function