fixed error handling

fixed error handling on correct thread