ra: Pull the body of a loop out to a helper function.