register events automatically