optimizing select, deselect