Fix missing study instantiation. Fixes #219

This is a quick fix for the issue. Just forgot to instantiate studies in the second for loop, so it was constantly using the last study from the first for loop.