Patch to increase the robustness of sim1.m