Fixed error in MAP calculation