You should check for the amount of selections *before* changing anything. Right now, if there are multiple selections and some of them contain text, the first `if` will clear them, which isn't what you intended, I assume.