Moved code to defTable class
Minor improvement with button logic.