fixed recursive loop on some platforms