refactor mutual recursion towards simple recursion