now using case rather than table name