Moved Ty's database code to his controller.