Joystick Detection Script (Small) help

I’m pulling my controller in and out but it doesn’t seem to update well. Never once it told me “Controller disconnected”.

void Update()
{
    if (Input.GetJoystickNames().Length > 0)
    {
        Debug.Log("Controller connected");
    }
    else
    {
        Debug.Log("Controller disconnected");
    }
}