                 configs["title"] = lastTitle
             }
             javaScriptBridge.callJSMethod("resetState", parameter: configs, completionHandler: nil)
-        } else if let query = lastQuery { // the app was closed while searching
+        } else if let query = LocalDataStore.objectForKey(lastQueryKey) { // the app was closed while searching
             configs["q"] = query
             // get current location if possible
             if let currentLocation = LocationManager.sharedInstance.location {


		KeyboardHelper.defaultHelper.addDelegate(self)
		layoutSearchEngineScrollView()
        lastQuery = LocalDataStore.objectForKey(lastQueryKey) as? String
	}

    override func viewWillAppear(animated: Bool) {

		JSString = "search_mobile('\(q)'\(coordinates))"
		self.webView!.evaluateJavaScript(JSString, completionHandler: nil)

        lastQuery = query
	}
    
    func updatePrivateMode(privateMode: Bool) {
