Don't be scare of loops inside loops. It is a VERY common practice. I think I've gone further than 7 loops deep before.