refine scripts