Finished get tables logic