balancing AI investment and profitability