Solving Programming Assignment 2