Completed checkpoint 18 Loops functions