refactor qalloc