Moved events to the init function