simplified the resource.is_valid invalid test.
simplified the resouce.is_valid test.