Element 'border detection algorithm'