Modified assignment5 according the requirements