adopt script to new port detecting method