Mutex unlock was in wrong place