add events + fix some bugs