Add exception handling and configuration file