Fixed port checking code.