updated directory check