refactor
safer port sniffing