fixed undefined scope var