select/unselect all when select/unselect items, some rafactoring