added inner-outer iteration method