fix error handling, only x backend, other backends should be rewritten too