typo fixed and missing global var declared