added some comments after code review