Made the script idempotent