Prepare code for loop