K.Hamren version of programming assignment 2