Your size mod expression is probably not what you intend (size -1 +1), maybe a typo?
The value in ch is not necessarily zero, so explicitly set it to zero first, or better yet, use = instead of += in those lines.
Dang! ntubski was faster on the submit!