Fixed recursive loop