reworking loops, first successful compile