Fix function scope & typo