Refactored to be less duplicated. REOL-21