added lots of comments everywhere