select logic