Simplifying index.js by extracting core/connect.js