Improved iframe resize logic