retrieve the path extension only once
use sets data structures to optimize lookups