removed logic for finding local as it was unnecessary and added comments throughout