This is the code from programming assignement 2