changed path builder to use sets instead of arrays, alleviates the problem of duplication