adding nested loops