 
           bucketIndex = @getBucketIndexByZoomedAddress(subBucket)
               
-          cube[bucketIndex] = substitute if cube[bucketIndex] == bucket
+          cube[bucketIndex] = substitute if cube[bucketIndex] == oldBucket
 
 
   # remove buckets until cube is within bucketCount-limit

      bucketIndex = @getBucketIndexByZoomedAddress(address)

      @bucketCount++
      @access.unshift([bucket_x, bucket_y, bucket_z, zoomStep])
      bucketData.access = 1
      bucketData.zoomStep = zoomStep

      cube[bucketIndex] = bucketData

      setArbitraryBucketByZoomedAddress(address, bucketData) if zoomStep <= @ARBITRARY_MAX_ZOOMSTEP

      @trigger("bucketLoaded", [bucket_x, bucket_y, bucket_z, zoomStep])


  setArbitraryBucketByZoomedAddress : ([bucket_x, bucket_y, bucket_z, zoomStep], bucketData) ->

    cube = @cubes[address[3]]
    bucketIndex = @getBucketIndexByZoomedAddress(address)

    if bucketIndex? and (bucket = cube[bucketIndex]) != @LOADING_PLACEHOLDER
      bucket
    else
      null
