trying to implement deep chaining recursively