Added event detection functions