implement random hash function