Clean some code using event