Leverage block/yield to refactor repetitive code