fixed NULL bug