add better error handling and messaging