improved way to set data and schema to NewResource.