Added implementation for handling selection.