Refactor openPath into a util file.