find base dir more reliably