adding some error handling and a separate config file