amended to work with cfg file