Modify the following Python code to use a loop instead of recursion.
def GCD(x, y):
if y == 0:
 return x
 else:
 return GCD(y, x%y)
def GCD(x, y):
    while(y != 0):
        temp = y
        y = x % y
        x = temp
    return x