fixed 'undefined variable' issue