fix nullpointer bugs