Added the option to return the index of selected sources