                 fetch = () ->
                   direction = pending[0]
                   #console.log "Running fetch... #{{true:'bottom', false: 'top'}[direction]} pending #{pending.length}"
+                  lastScope = null
                   if direction
                     if buffer.length && !shouldLoadBottom()
                       finalize()

                          finalize()
                          return
                        for item in result
                          insert item, false
                        next += result.length
                        console.log "appended: #{result.length} buffer size #{buffer.length} first #{first} next #{next}"
                        finalize()
                        adjustBuffer()

                  else
                    if buffer.length && !shouldLoadTop()

                      buffer.push wrapper
                  # using watch is the only way I found to gather the 'real' height of the thing - the height after the item
                  # template was processed and values inserted.
                  itemScope.$watch 'heightAdjustment', ->
                    if top
                      newHeight = topPadding.height() - wrapper.element.outerHeight(true)
                      if newHeight >= 0
                        topPadding.height(newHeight)
                      else
                        scrollTop = viewport.scrollTop() + wrapper.element.outerHeight(true)
                        if viewport.height() + scrollTop > canvas.height()
                          bottomPadding.height(bottomPadding.height() + viewport.height() + scrollTop - canvas.height())
                        viewport.scrollTop(scrollTop)
                    else
                      bottomPadding.height(Math.max(0,bottomPadding.height() - wrapper.element.outerHeight(true)))
                    console.log "item = " + wrapper.element.text()

                  itemScope


                finalize = ->
                  pending.shift()
