Condensed if statements into a for loop.