Final version of the script