Updating code snippet for Custom Events