bug fix printing and encoding