bug fixing according to jslint - finished