Fix select logic