refactored server.js slightly