written in c using hash function