fix resource could be None