updated check for directory