Format loop function.