replaced operation to get next table by using random.nextInt()