added more documentation to code