uncommented HMM function