Effect of Mg on the dielectric and electrical properties of BaTiO3-based ceramics