bug fix for event registration function