refacotoring table generation