getPath function modified