fix ports and substr