working with four loops