Almost working with not to so horrible code as before. Iteration over MA0 is to be checked