Added a check for tables and create tables