Thanks to Jake Holmes for the marvelous code.