modified for directory variable