Second version of programming assignment 2