Fixing the locking issue #2