refactor to make base case broader