Fix directory check