Added a new sub function, check_resource, to check the resource before adding instances