fix bug in hash function