HMM for CF algorithm