trying to remove some explicit recursion