Added output directory check instead of crashing