Implemented functions required in Assignment2