2 loops approach