Adding locking to prevent concurrent script runs