Refactoring cq