seemingly working code without parsing ports