query refactoring; persistence wip