Implemented necessary functions for the assignment.