Additional Comments were added to explain the code.