Fixed the recursive loop