Added try/catch to support IE7