fix strange condition with empty ports string.