Updated the path function