rotate an object by 180° on click only once

Heyo, so I need to make it so that a 3d-object rotates only once after mouse click. The code I have works, but the object rotates every time I click on it and I need it to do it only once.
Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateOnce : MonoBehaviour
{
public float smooth = 1f;
private Vector3 targetAngles;

 void Update () 
 {
     if(Input.GetKeyDown(KeyCode.Mouse0)) 
     targetAngles = transform.eulerAngles + 180f * Vector3.up; 

     transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, targetAngles, smooth * Time.deltaTime); 
 }

}

You can use a bool here

private bool alreadyRotated = false;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (alreadyRotated == false)
            {
                targetAngles = transform.eulerAngles + 180f * Vector3.up;
                transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, targetAngles, smooth * Time.deltaTime);
                alreadyRotated = true;
            }
        } 
    }