Adding valid_resource function