The above block is used in a number of places; encapsulate it into a method.