Trying to prevent IllegalStateException + not adding empty scripts