Implemented the two functions for the assignment