Added Loops and Logic