Instead of calling this logic recursively, why not make it a helper method?