fixed subtle recursion bug (recursed to outer function, not helper)