Smelting is a form of extractive metallurgy; its main use is to produce a base metal from its ore. This includes the production of silver, iron, copper and other base metals from their ores. Smelting makes use of heat and a chemical reducing agent to decompose the ore, driving off other elements as gases or slag and leaving just the metal base behind. The reducing agent is commonly a source of carbon such as coke, or in earlier times charcoal. The carbon (or carbon monoxide derived from it) removes oxygen from the ore, leaving behind the elemental metal. The carbon is thus oxidized in two stages, producing first carbon monoxide and then carbon dioxide. As most ores are impure, it is often necessary to use flux, such as limestone, to remove the accompanying rock gangue as slag.