Fixed the array index out of bounds exception in MAP