server.js file cleaned up and database-queries improved