better error handling and config detection