fixed bug in general gmm, but slows down a lot