Changed directory check to -d