       return
     }
     
+    // create data task
     let task = NSURLSession.sharedSession().dataTaskWithURL(url) { data, response, error in
       
       guard let httpResponse = response as? NSHTTPURLResponse else { return }

      mainQueue { completion(json, nil) }
    }
    
    task.resume()
  }
  

  
  // MARK: - Search Function
  
  public func searchFor(search: String, mediaType: Media? = nil, completion: (JSON?, Error?) -> Void) {
    
    // encode search term
    guard let escapedString = URLEscapedString(search) else {
      completion(nil, .InvalidSearchTerm)
      return
    }
    
    let term = NSURLQueryItem(name: "term", value: escapedString)
    
    // build url
    guard let url = URLWithQueryItems([term]) else {
