Extract the code for inserting a loop into the loop queue into