attempt at better directory inference