correcting logic in server.js