Created action to switch between selections

Moved code from the GUI to the action where it belongs