refactor port.js