Script should now work after some testing