moved logics into the events