(added) - added some error handling