Update main.js

Fixing the issue where the port number is overwritten with handleSelect() function even though there was a successful connection before.