add EventListeners to clean the duplicated code