reimplements db queries