Slightly refactored Prime paths generator