Modeified the code according to the requirements