Implemented as per assignment.