added directory check