refine script.