 							item.scope.$index = first + i for item,i in buffer
 							adjustBuffer()
 
-						adapter.insert = (locator, item) ->
+						doInsert = (locator, item) ->
 							inserted = []
 							if angular.isFunction locator
 								throw new Error('not implemented - Insert with locator function')


						angular.extend(adapterAttr, adapter) if adapterAttr

						# deprecated since v1.1.0
						adapter.update = (locator, newItem) ->
							if angular.isFunction locator
								((wrapper)->
									locator wrapper.scope

						# Calling linker is the only way I found to get access to the tag name of the template
						# to prevent the directive scope from pollution a new scope is created and destroyed
						# right after the repeaterHandler creation is completed
						linker $scope.$new(), (template) ->

							repeaterType = template[0].localName
							if repeaterType in ['dl']
								throw new Error "ui-scroll directive does not support <#{template[0].localName}> as a repeating tag: #{template[0].outerHTML}"
							repeaterType = 'div' if repeaterType not in ['li', 'tr']

							viewport = if controllers[0] and controllers[0].viewport then controllers[0].viewport else angular.element(window)
							viewport.css({'overflow-y': 'auto', 'display': 'block'})

							padding = (repeaterType)->
								switch repeaterType
									when 'tr'
										table = angular.element('<table><tr><td><div></div></td></tr></table>')
										div = table.find('div')
										result = table.find('tr')
										result.paddingHeight = -> div.height.apply(div, arguments)
										result
									else
										result = angular.element("<#{repeaterType}></#{repeaterType}>")
										result.paddingHeight = result.height
										result

							createPadding = (padding, element, direction) ->
								element[{top:'before',bottom:'after'}[direction]] padding
								paddingHeight: -> padding.paddingHeight.apply(padding, arguments)
								insert: (element) -> padding[{top:'after',bottom:'before'}[direction]] element

							topPadding = createPadding(padding(repeaterType), element, 'top')
							bottomPadding = createPadding(padding(repeaterType), element, 'bottom')

							$scope.$on '$destroy', template.remove

							builder =
								viewport: viewport
								topPadding: topPadding.paddingHeight
								bottomPadding: bottomPadding.paddingHeight
								append: bottomPadding.insert
								prepend: topPadding.insert
								bottomDataPos: ->
									scrollHeight(viewport) - bottomPadding.paddingHeight()
								topDataPos: ->
									topPadding.paddingHeight()

						viewport = builder.viewport

