Restructuring server.js