added thread safety