Thread safety fix