code refine on xsql.sh