         # We check for game state in either the frame (CODAP API 2.0) or the dataContext
         # (API 1.0). We ignore the dataContext if we find game state in the interactiveFrame
         state = frame?.values.savedState or
-                context?.values.contextStorage.gameState
+                context?.values.contextStorage?.gameState
 
         if state?
           @graphStore.deleteAll()

      if ret?.success
        @initGameHandler ret
      else
        @codapPhone.call
          action: 'create',
          resource: 'dataContext',
          values: {
            name: 'Sage Simulation',
            title: 'Sage Simulation'
            collections: [ {
              name: 'Simulation',
              title: 'Sage Simulation',
              labels: {
                singleCase: 'run',
                pluralCase: 'runs'
              },
              attrs: [
                  {
                    name: tr '~CODAP.SIMULATION.EXPERIMENT'
                    type: 'numeric'
                  }
                ]
              },
              {
                parent: "Simulation",
                name: 'Samples',
                title: 'Samples',
                labels: {
                  singleCase: 'sample',
                  pluralCase: 'samples'
                }
                attrs: sampleDataAttrs
              }
            ]
          }
        , @initGameHandler

  _openNewCase: ->
    @caseOpened = true
    caseData = {}
    caseData[tr '~CODAP.SIMULATION.EXPERIMENT'] = SimulationStore.store.settings.experimentNumber
    @currentCaseID = null
    collectionAction = @_createCollection()

    @codapPhone.call([
      collectionAction,
      {
        action: 'create'
        resource: 'dataContext[Sage Simulation].collection[Simulation].case',
        values: { values: caseData }
      }
    ]
    , (result) =>
      if result?
        [collectionResponse, caseResponse] = result

        if caseResponse.success
          @currentCaseID = caseResponse.values[0].id
          @_flushQueue()
          if not @standaloneMode
            @createTable()
        else
          log.info "CODAP returned an error on 'openCase'"
    )

  _createCollection: ->
    nodes = @graphStore.getNodes()

    # First column definition is the time index

        log.info "null response in codap-connect codapPhone.call"
    )


    # check if we already have a datacontext (if we're opening a saved model).
    # if we don't create one with our collections. Then kick off init
