Use generators in the multiple_measurements function to reduce memory usage Alternatively to find a more optimal way rather than for loops