fixed bug in table function