final version, passed all tests except 16. because I did a different
implementation for catalog of table