test
refactor event detection