cleaned up code according to jslint recommendations