refactor queue