refactor selection logic to include edit