I have done a 50 minute connection in Miami with American and made it to my gate as boarding was starting. 40 minutes is doable if flight is on time and you can go from gate to gate in 20 minutes or less.