improved thread safety