Refactor queue