refactory queue selector logic.