finished the two functions for the assignment