broke database code into service