added concurent write to thread, not working correctly