adds synchronization using sync.RWMutex