HMM example code