New strategy for magnetic gas sensing