Add thread safety