changed implementation of hash function