fix issue #4 and more nesting