merge loops