Interesting pattern. I'd probably split this into a separate function though.