Fixing var not defined