Refactor path generation