events handling optimisation