fixed infinite loop in mr script