refactor d_script