Working version of script.