solution to simplifyPath