Problem changing TimeScale

I’m trying to pause and unpause a small game by setting the timescale to 0 and then back to 1 to unpause using this script:

bool paused=false;

void Update () 
	{
		if (Input.GetKeyDown(KeyCode.Escape))
		{
			Debug.Log ("esc: "+paused);

			if (paused)
			{
				Debug.Log("unpause");
				Time.timeScale=1;
				paused=false;
			}
			if(!paused)
			{
				Time.timeScale=0;
				paused=true;
			}
			Debug.Log (paused + " "+Time.timeScale);
		}
	}

Pressing Esc twice in game prints this to the console

esc: False
True 0

esc: True
unpause
True 0

The if(paused) loop is being called but the timescale and paused lines are not being run.

Any help is appreciated.

if(paused) set the bool = false, so the if(!paused) is now true and it executes it. Restructure this to something like

if (Input.GetKeyDown (KeyCode.Escape)) {
							if (!paused) {
									Time.timeScale = 0;
									paused = true;
							} else {
									paused = false;
									Time.timeScale = 1;
							}


					}