improving script efficiency