fix use undefined variable bug