fix bugs and add edit to tables