reworked currently selected table (and global variables)