Rewrite parts of handleclick