Refactoring get path method