slightly improved hash function