dynamic table saving work, just need refractor the code a bit