Dryed up a few functions in server.js