simplify error handling (2)
simplify encoding handling