Seems you need to think a bit more about what you mean by "not working", otherwise there isn't anything to change
A good start is to consider what it's supposed to be doing according to the instructions, and then testing the code to find out whether it's doing those things. The first thing that it isn't doing would then be what needs to be different
Presumably a hash supports some operations that are useful to carrying out the described tasks? There are probably many other ways of going about accomplishing the same thing.