introduce proper hmm functions