jsHint shows too many "var"s in this method :)