some modification to MRI code