refine script for generate script