Revert "Refactoring of query usage"

This reverts commit 9123fabde76eabe8786c7367aeb6a3a00d86e9a5.
Refactoring