improved output handling for script_weak