optimize selector algorithm