Updating registerForEvent() function.