Feature/pdsc 9 refactor database queries