just set a variable here (like `insertBeforeContainer`) and do the append after the loop