big refactorization
add query implementation
merge conflict
Revert "merge conflict"

This reverts commit 697dfb5d2ec7de7863f1fa41150f3f56454ca5bb.
merge conflict