First attempt at implementing loops