Added safety meaaures for errors