fixed event handler by using .on() method