Implemented the functions for Assignment 2