Change recursion from right to left