Remove duplicate code by defining the block first then using it as needed.