Changes to recursive function