Test there are column names for table (i.e. table exists) before attempting to use them

I've simply added guard conditions around the code that uses the column names to prevent the process from crashing when a request is made for a table that does not exist. Should also return an appropriate error response - 404 maybe?