Changed to map in recursive function.