fixed a mutex issue for opitimization