added mutex acquisition error handling