Moving MAP object inside the function