Moved selection code to model