Have a look at my Independent Randomisation and Trial Switching online demos. I preload one list before the main loop.