added some comments where needed