Refactor valid path