I wrote the two functions for the assignment