   
   # Request FITS files for each channel
   requestChannels: ->
-    @initWebFITS()
-    
-    # Set various deferred objects to handle asynchronous requests.
-    @dfs =
-      u: new $.Deferred()
-      g: new $.Deferred()
-      r: new $.Deferred()
-      i: new $.Deferred()
-      z: new $.Deferred()
+    @dfWebfits.then =>
+      @initWebFITS()
+    
+      # Set various deferred objects to handle asynchronous requests.
+      @dfs =
+        u: new $.Deferred()
+        g: new $.Deferred()
+        r: new $.Deferred()
+        i: new $.Deferred()
+        z: new $.Deferred()
    
-    subject = @currentPageData()[0]
-    prefix  = subject.metadata.id
-    
-    # Set callback for when all channels and WebFITS Api received
-    $.when.apply(null, _.values(@dfs))
-      .done(@allChannelsReceived)
-    
-    for band, index in @bands
-      do (band, index) =>
-        path = "#{@source}#{prefix}_#{band}.fits.fz"
+      subject = @currentPageData()[0]
+      prefix  = subject.metadata.id
+    
+      # Set callback for when all channels and WebFITS Api received
+      $.when.apply(null, _.values(@dfs))
+        .done(@allChannelsReceived)
+      
+      for band, index in @bands
+        do (band, index) =>
+          path = "#{@source}#{prefix}_#{band}.fits.fz"
         
-        new astro.FITS.File(path, (fits) =>
-          hdu = fits.getHDU()
-          header = hdu.header
-          dataunit = hdu.data
+          new astro.FITS.File(path, (fits) =>
+            hdu = fits.getHDU()
+            header = hdu.header
+            dataunit = hdu.data
           
-          # Get image data
-          dataunit.getFrameAsync(0, (arr) =>
+            # Get image data
+            dataunit.getFrameAsync(0, (arr) =>
             
-            # Compute extent
-            [min, max] = dataunit.getExtent(arr)
-
-            # Initialize a model and push to collection
-            layer = new Layer({band: band, fits: fits, minimum: min, maximum: max})
-            @collection.add(layer)
-
-            # Load texture
-            @wfits.loadImage(band, arr, dataunit.width, dataunit.height)
-            @dfs[band].resolve()
+              # Compute extent
+              [min, max] = dataunit.getExtent(arr)
+
+              # Initialize a model and push to collection
+              layer = new Layer({band: band, fits: fits, minimum: min, maximum: max})
+              @collection.add(layer)
+
+              # Load texture
+              @wfits.loadImage(band, arr, dataunit.width, dataunit.height)
+              @dfs[band].resolve()
+            )
           )
-        )
   
   # Initialize a WebFITS object
   initWebFITS: =>
     @wfits?.teardown()
-    
+   
     @wfits = new astro.WebFITS(@el, @dimension)
     
     unless @wfits.ctx?


#
# Define collection and model used in viewer
#

# Collection of layers where each layer corresponds to a FITS image
class Layers extends Backbone.Collection
  hasExtent: false

    
    # Set various deferred objects to handle asynchronous requests.
    @dfs =
      u: new $.Deferred()
      g: new $.Deferred()
      r: new $.Deferred()
      i: new $.Deferred()
      z: new $.Deferred()


    @dfWebfits = new $.Deferred()
    
    @getApi()
  
