Glitch in Shooting script

Hi guys.

My problem is that after writing my code for my shooting script I have run into an glitch that when i press play on the editor it starts shooting by itself as long as it is aiming at an actual game object. For example if aiming at floor it will auto fire, when looking at my box opposite to my character it auto fires. However if i look up to the sky it stops auto firing and then aim at a game object again it starts firing. I know this as every frame it prints out on the console we hit then the object that I was aiming at and the fact that it destroys my box in less than a second after starting the game without having to do anything. I know it stops when looking to the sky as the console stops printing and then starts printing again when i aim at a game object.

When it auto fires it does not spawn the bullets that I have told my script to nor follows the cool down period. However if I click on the shoot key it will shoot as it is supposed to (spawning my bullets and following the 1 second countdown) and even works when aiming at the sky.

using UnityEngine;
using System.Collections;

public class Shoot : MonoBehaviour {
  
    public GameObject bullet_prefab;
    public GameObject Shootpoint;
    float bulletSpeed = 20f;
    float damage = 20f;

    public float cooldown = 1.0f;
    float cooldownRemaining = 0;

   // Update is called once per frame
    void Update () {
        cooldownRemaining -= Time.deltaTime;
      
            if (Input.GetButtonDown ("Fire1") && cooldownRemaining <= 0) {
                        cooldownRemaining = cooldown;

                        GameObject bullet = (GameObject)Instantiate (bullet_prefab, Shootpoint.transform.position + Shootpoint.transform.forward, Shootpoint.transform.rotation);
                        bullet.rigidbody.AddForce (Shootpoint.transform.forward * bulletSpeed, ForceMode.Impulse);
                }

                        Ray ray = new Ray(Shootpoint.transform.position, Shootpoint.transform.forward);
                        Transform hitTransform;
                        Vector3   hitPoint;

                        hitTransform = FindClosestHitObject (ray, out hitPoint);

                        if(hitTransform != null) {
                                Debug.Log ("We hit; " + hitTransform.name);

                                Health h = hitTransform.GetComponent<Health>();

                                if(h != null) {
                                        h.TakeDamage ( damage );
                                }
                        }
                }

            Transform FindClosestHitObject (Ray ray, out Vector3 hitPoint) {

                RaycastHit[] hits = Physics.RaycastAll(ray);

                Transform closestHit = null;
                float distance = 0;
                hitPoint = Vector3.zero;

                foreach (RaycastHit hit in hits) {
                        if(hit.transform != this.transform && ( closestHit==null || hit.distance < distance ) ) {
                              
                                closestHit = hit.transform;
                                distance = hit.distance;
                                hitPoint = hit.point;
                        }
                }
          
                return closestHit;

        }
}

I have looked and compared code to the original tutorial that I was following and can not see any problem in the code. It would be a great help if you could help me identify the problem behind this issue.

Thanks.

Move the closing bracket from line 23 to line 41.

Thanks for your help