fixed bug: using undefined variable