(There are even cleaner ways, but I think that will do it, codewise and perfowise)