added some error checking and using a central file for paths. still needs to be tested and improved.