This looks like a perfect candidate for a helper, seeing as it's repeated on line 28.