Refactor for DRYness.