improve performance of hash fn