Factor out duplicate code.