added event system to the registration function