filled in the body of the 2 functions for assignment2