Refactoring of Queries