Implemented the functions required for the assignment