Fixed undefined var bug and removed console.log