Refacting for DRY code