ProgrammingAssignment2 functions