adding hopefully better error handling