Added more documentation to the code