Just moved the code around a little so that the server.js remains as clean as possible