finished assignment 2 for Coursera's rprog-003 course