Separated some code into a middleware file ... wanted to see if that looked good.