I see what you meant with duplicate code now. The best way to get rid of this would have been to factor out the utility code (ie, make a getSelectedIndices).
Then again, the overhead is pretty minimal, so it's not really needed.