refactored server.js