added a way to deal with errors