You're right, that also works. I prefer the second format as it removes the need for the temporary variable and only writes once to selection.
Do you like the idea of having a separate function for this? I personally do, you never know when you want to do the same in another context