Completed the two functions for assignment 2

Completed the two functions for assignment 2