Finished first version of the script