Make thread-safe