Added a hacked version of event detection