fix handling of msg to treat empty str as nil