REVIEW-4221: Pulled out method into reusable class.