added mpr and bug fix due to uapply not working