recursive func worked