fixed most bugs and get the table worked