Averaging function - page 2

In the expert you need to check all the logic. There are minor bugs. But the logic breaks because of them.