fixed crash but occasional exit before whole simulation