initial commit with a fully working version of the script