refactored server.js and routes.js