Corrected JsDoc definition
renamed variables, added, argument checking, added JsDoc definition