Fixing double releasing a lock