added documentation to the code