Change program to take in loops