Finished abstracting logic from route file