Fixed var issue, should solve the error in console