Implemented functions as per assignment