updated the code with output.