creating the main.js file which supports both auto connection and on user demand connection in one single function without creating global variables. To do so the old main.js file got renamed to mainconn.js file