add rudimentary error handling