BUG: fix undefined variable