revised selection code