fix mutex logic