Modified assignment 8 according to the requirements