partly refactored to have most db stuff in 1 service (work still needed)