             # not intended to be beautified
             return resolve( null )
         else
-          # TODO: select appropriate language
-          language = languages[0]
-
           logger.verbose("Language #{language.name} supported")
 
           # Get language config
           langDisabled = atom.config.get("atom-beautify.#{language.namespace}.disabled")
 
-
           # Beautify!
           unsupportedGrammar = false
-
 
           # Check if Language is disabled
           if langDisabled

        logger.info('beautify', text, allOptions, grammar, filePath, onSave)
        logger.verbose(allOptions)

        # Get language
        fileExtension = path.extname(filePath)
        # Remove prefix "." (period) in fileExtension
        fileExtension = fileExtension.substr(1)
        languages = @languages.getLanguages({grammar, extension: fileExtension})
        logger.verbose(languages, grammar, fileExtension)

        # Check if unsupported language
        if languages.length < 1
          unsupportedGrammar = true

          logger.verbose('Unsupported language')

          if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors")
            return resolve( null )
          else
            fileExtension = @getExtension(filePath)
            repoBugsUrl = pkg.bugs.url
            title = "Atom Beautify could not find a supported beautifier for this file"
            detail = """
