Finalized new ENCODER.R