Implemented inner and outter EC.