COmpleted the functions for the assignment