added conditional logic around JSclick