added HMM code