refactoring: moving the connection logic from Main.js to a separate service called "ConnectionUtils"