is there a reason you use `[ -f ... ]` form earlier but `test -d ...` form here?