added averaging to EM