Fixed errors on convertoldmagres script