fixing crashing issue when creating a new resource