added code for avoiding duplication of savePath