Synthesis and characterization of heterocyclic compounds and their application as corrosion inhibitor