           if (new Date(). getTime() - start_time) > 5000
             console.log 'waiting for too long... i will try again'
             get_from_flickr = true
+            console.log "Headers are already sent: " + res.headerSent
             if get_from_db == true and not res.headerSent
               res.send result
               

      try
        request.get req_uri, (error, rsp, data) ->
          if error
            console.log 'Error: ' + error
          else
            counter += 1
            console.log counter

  request.get req_url, (err, resp, body) ->
    if err
      console.log 'Error: ' + err
      res.send []
      return
      
    photos = JSON.parse(String(body).slice 14, -1).photos.photo
    
    if photos.length == 0
