better logic for the dataselection