char out of range bug fix