modified hash implementation from instructor comments on program 1