added dom event handling code