insert_resource function with string indexing