implemented next() of the tablescan