Optimzied the script.