shorter code for table without for loop