adding functionalty to calculate events