Added error checking for getting the path.