move logic from routes file into controllers