completely restructured application and revised server.js