Refactor bql