Refine scripts