Added a boolean variable and more cmmts