avoiding infinite recursive loop