Added directory check