Can now handle arbitrary nesting