Walmart formally agrees to buy a controlling stake in Flipkart