                   #globals.doPositioning && globals.selectedText &&
                   #(buffer.length == 0 || scope.defaultText(buffer[buffer.length-1]).toLowerCase() <= globals.selectedText.toLowerCase()) ||
                   # and we have enough for the scrollbar to show up
+
                   item = buffer[buffer.length-1]
-                  if item
-                    !eof && item.element.offset().top - canvas.offset().top + item.element.outerHeight(true) <
-                      viewport.scrollTop() + viewport.height() + bufferPadding()
-                  else
-                    true
+                  !eof && item.element.offset().top - canvas.offset().top + item.element.outerHeight(true) <
+                    viewport.scrollTop() + viewport.height() + bufferPadding()
 
                 clipBottom = ->
-                    # clip off the invisible items form the bottom
+                    # clip the invisible items off the bottom
                   bottomHeight = bottomPadding.height()
                   overage = 0
 
-                  for i in [buffer.length-1..0]
-                    itemHeight = buffer[i].element.outerHeight(true)
-                    if viewport.scrollTop() + viewport.height() + bufferPadding() < buffer[i].element.offset().top - canvas.offset().top
-                      bottomHeight += itemHeight
+                  for item in buffer[..].reverse()
+                    if viewport.scrollTop() + viewport.height() + bufferPadding() < item.element.offset().top - canvas.offset().top
+                      bottomHeight += item.element.outerHeight(true)
                       overage++
                       eof = false
                     else

    ])

  .directive( 'ngScroll'
    [ '$log', '$injector', '$timeout'
      (console, $injector, $timeout) ->
        require: ['?^ngScrollViewport', '?^ngScrollCanvas']
        transclude: 'element'
        priority: 1000

                  direction = pending[0]
                  #console.log "Running fetch... #{{true:'bottom', false: 'top'}[direction]} pending #{pending.length}"
                  if direction
                    if buffer.length && !shouldLoadBottom()
                      finalize()
                    else
                      #console.log "appending... requested #{bufferSize} records starting from #{next}"
