Added a bit more documentation to the code