add some basic error catching