wrote recursive transform