BUG: fix unbound variable bug