three level nested loop