add check for null msg to prevent exception error.