fixed exeption and encoding issues