made some of reviewer's fixes and commented with some todo
removed trailing whitespace