implemented the gmm