   return priceText
 }
 
-private func randomImageURL() -> URL {
-  let randomImageNumber = Int(arc4random_uniform(22)) + 1
-  let randomImageURLString =
-  "https://storage.googleapis.com/firestorequickstarts.appspot.com/food_\(randomImageNumber).png"
-  return URL(string: randomImageURLString)!
+private func imageURL(from string: String) -> URL {
+  let number = (string.hashValue % 22) + 1
+  let URLString =
+      "https://storage.googleapis.com/firestorequickstarts.appspot.com/food_\(number).png"
+  return URL(string: URLString)!
 }
 
 class RestaurantsTableViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

    starsView.rating = Int(restaurant.averageRating.rounded())
    priceLabel.text = priceString(from: restaurant.price)

    let imageURL = randomImageURL()
    thumbnailView.sd_setImage(with: imageURL)
  }

  override func prepareForReuse() {

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)
    let controller = RestaurantDetailViewController.fromStoryboard()
    controller.titleImageURL = imageURL(from: restaurants[indexPath.row].name)
    controller.restaurant = restaurants[indexPath.row]
    controller.restaurantReference = documents[indexPath.row].reference
    self.navigationController?.pushViewController(controller, animated: true)
