diff --git a/tools/tools.go b/tools/tools.go
index 88ef425ea..53892b22a 100644
--- a/tools/tools.go
+++ b/tools/tools.go
@@ -101,9 +101,9 @@ func (t *Tools) GetLocation(command string) (string, error) {
 
 // writeMap() writes installed map to the json file "installed.json"
 func (t *Tools) writeMap() error {
-	t.mutex.RLock()
+	t.mutex.Lock()
 	b, err := json.Marshal(t.installed)
-	t.mutex.RUnlock()
+	defer t.mutex.Unlock()
 	if err != nil {
 		return err
 	}
@@ -113,13 +113,13 @@ func (t *Tools) writeMap() error {
 
 // readMap() reads the installed map from json file "installed.json"
 func (t *Tools) readMap() error {
+	t.mutex.Lock()
+	defer t.mutex.Unlock()
 	filePath := path.Join(dir(), "installed.json")
 	b, err := ioutil.ReadFile(filePath)
 	if err != nil {
 		return err
 	}
-	t.mutex.Lock()
-	defer t.mutex.Unlock()
 	return json.Unmarshal(b, &t.installed)
 }