working on outer loops