Refactor Hmm