fix a crash issue and cannot locate file correctly sometimes