rewrite click function