Created a service layer to simplify the code somewhat.