uses variables of line counts to do the loop, but still feels sloppy