Thanks for your answer i was willing to do all the stuff in a function but i realize that i must separate all case and test/add the timestamp directly in the events.