pull out repeated selection logic