fix possible resource error