fix undefined variable problem