Fix bug in click event handler