     self.placeType = placeType
   }
   
-  public func getPlaces(searchString: String, completion:([Place] -> Void)) {
+  public func getPlaces(searchString: String, completion:(([Place]?, NSError?) -> Void)) {
     var params = [
       "input": searchString,
       "types": placeType.description,

    GooglePlacesRequestHelpers.doRequest(
      "https://maps.googleapis.com/maps/api/place/autocomplete/json",
      params: params
      ) { json in
        if let predictions = json["predictions"] as? Array<[String: AnyObject]> {
          self.places = predictions.map { (prediction: [String: AnyObject]) -> Place in
            return Place(prediction: prediction, apiKey: self.apiKey)
          }
          self.delegate?.placesFound?(self.places)
          completion(self.places)

        }
    }
  }

    return CFURLCreateStringByAddingPercentEscapes(nil, string, nil, legalURLCharactersToBeEscaped, CFStringBuiltInEncodings.UTF8.rawValue) as String
  }

  private class func doRequest(url: String, params: [String: String], completion: (NSDictionary?,NSError?) -> ()) {
    var request = NSMutableURLRequest(
      URL: NSURL(string: "\(url)?\(query(params))")!
    )

    var session = NSURLSession.sharedSession()
    var task = session.dataTaskWithRequest(request) { data, response, error in
      self.handleResponse(data, response: response as? NSHTTPURLResponse, error: error, completion: completion)
    }

    task.resume()
  }

  private class func handleResponse(data: NSData!, response: NSHTTPURLResponse!, error: NSError!, completion: (NSDictionary?, NSError?) -> ()) {
    
    // Perform table updates on UI thread
    let done: ((NSDictionary?, NSError?) -> Void) = {(json, error) in
        dispatch_async(dispatch_get_main_queue(), {
            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
            completion(json,error)
        })
    }
    
    if let error = error {
      println("GooglePlaces Error: \(error.localizedDescription)")
      done(nil,error)
      return
    }

    if response == nil {
      println("GooglePlaces Error: No response from API")
        let error = NSError(domain: ErrorDomain, code: 1001, userInfo: [NSLocalizedDescriptionKey:"No response from API"])
      done(nil,error)
      return
    }

    if response.statusCode != 200 {
      println("GooglePlaces Error: Invalid status code \(response.statusCode) from API")
    let error = NSError(domain: ErrorDomain, code: response.statusCode, userInfo: [NSLocalizedDescriptionKey:"Invalid status code"])
      done(nil,error)
      return
    }

