fix some issues with null pointer