Fixed bug in hash function