add config file and more error checking