Effect of the Magnetic Field on the Propagation of Coronal Mass Ejections