Moved selection logic into code.