updated click event timing to fix the double click bug