As above, maybe wrap this in a function, if for no other reason than to give it a name, since it's pretty obscure what it does.