fix a null variable bug