changed events to use the array length rather than hardcoded.