refactor: add sanity check to worker script handling