moved event handler from onclick to addeventlistener