queue refactoring