implemented string hash function