added small thread security