Add function to trim the path