nested loop and swap letters