Tidied the error handler a bit more