Changed to an event listener pattern