Exract two loops