add some better error handling