New Version

Starting to split the script in functions