Corrected the SQL query to prevent duplicate events in Dictionairy.