Initial working version of script