improved recursive handling