Move the logic in a Event Listener