changed to event listener pattern