fixing bugs on msr, 1st working version