Refactor compute_fields