Homework 4 3) b) functions in place, probably needs debugging