typo and global declarations removed