fix recursive loop