Reworked to use configuration file to simplify some functions