initial stage of encoder