optimize the script