refactor shared logic of queue declaration