fix a bug of the table placing algorithm