working document encoder, fixed modulo 26 bug