I'm fine with the logic of the  return statement, I was simply suggesting to change from: 
```
QString studyUID;
foreach (studyUID, studiesUIDS)
```
into
```
foreach (const QString& studyUID, studiesUIDS)
```