fixed problems with using multiple tables