added some documentation to the code