4th attempt to fix warning

Corrects name of table in query from type to Type; better error checking