Refactor code to adhere DRY.