merged the extra loops into a single function + a bonus 30% more rows