fixed memory leak and fixed how the PATH is parsed and tested