Updated the cap event with new SQL query