finished writing encoding part