Troubleshooting the thread safe issue