Commented and documented the code