Modified function

Completed function for ProgrammingAssignment2