Q refactoring