My attempt at Programming Assignment 2