Fix unbound variable bug