implement most of E-step