Move db operations to service. Not yet complete