code reformat and change chat msg null logic