fix the premature waring and file not open issue