My final version of the Coursera  programming assignment 2