The system has built-in aggregations. If you use them, the code becomes simpler and more readable.

Also, where do you apply the dampening factor formula?