       version = loadedPackage?.metadata.version
       unless version
         try
-          version = Package.loadMetadata(@pack.name).version
-      @updateAvailable = semver.gt(@pack.version, version)
+          version = Package.loadMetadata(@metadata.name).version
+      @updateAvailable = semver.gt(@metadata.version, version)
 
     if @updateAvailable
       @update.show()

          @a 'Show README', outlet: 'readmeLink'
          @div class: 'readme', outlet: 'readme'

  installed: false
  disabled: false
  bundled: false
  updateAvailable: false

  initialize: (@pack, @packageEventEmitter) ->
    @updatePackageState()

    @attr('name', @pack.name)
    @name.text(@pack.name)
    if version = semver.valid(@pack.version)
      @version.text(version)
    else
      @version.hide()

    if @pack.descriptionHtml
      @description.html(@pack.descriptionHtml)
    else if @pack.description
      @description.text(@pack.description)
    else
      @description.text('No further description available.')

    @readme.hide()
    if @pack.readmeHtml
      @readme.html(pack.readmeHtml)
    else if @pack.readme
      @readme.text(@pack.readme)
    else
      @readmeArea.hide()


      if @installed
        if @updateAvailable
          @defaultAction.text('Upgrading\u2026')
          packageManager.install @metadata, (error) =>
            @packageEventEmitter.trigger('package-upgraded', error, @metadata)
        else
          @defaultAction.text('Uninstalling\u2026')
          packageManager.uninstall @metadata, (error) =>
            @packageEventEmitter.trigger('package-uninstalled', error, @metadata)
      else
        @defaultAction.text('Installing\u2026')
        packageManager.install @metadata, (error) =>
          @packageEventEmitter.trigger('package-installed', error, @metadata)

    @updateDefaultAction()

