select logic fixed