Added some error handling behaviour