bugfix: release the lock if returning earlier because the value didn't match