CCA fitting function