fix msg handling to treat empty str as nil