This looks like a good candidate for encapsulating into a method.