change to non-recursive