refactor for qat