do thread safety and stuff