Add error handling

sometimes this error occurs.