Handling invalid operation exception in a better manner for some scenarios.