click event not working perfectly