Added handle_selection code.