fixing js according to JsHint