Fixing setting port logic