Refactor label assignment and improve selection
Fix merging conflicts