hasSelection = selection.length > 0;
would be more efficient than looping