Refractor using event and optimize performance