TODO:optimize code, write statements, get ddl, and solv problem with buttons