common loop algorithms