fixed unbound variable bugs