memory optimize InsertEvents and return err