Improve selection handling