added some more comments in functions for coursera Programming Assignment 2