adding event listener to decouple ui from logic
updating ui happening on events
fixed object reference error