Function does make 8 rows in table but not in the correct format