         url: loginUrl
 
     request options, (err, res, body) ->
-        return next err if err
-
+        return next err if err or not res.headers.location?
         location = res.headers.location
         parameters = location.split('?')[1]
         url = "#{billUrl}?#{parameters}"

# Parse the fetched page to extract bill data.
parsePage = (requiredFields, bills, data, next) ->
    bills.fetched = []
    $ = cheerio.load data.html
    $('.pane li').each ->
        amount = $($(this).find('strong').get(1)).html()


        bill.pdfurl = pdfUrl if date.year() > 2011
        bills.fetched.push bill
    next()
