ran code through jslint, added some comments