Move db routines to service