modernize error handling