hash function optimization