added state NULL to fix NULL related bugs