fixed directory bug on error