refactored marshalling recursion