optimization of the script