Used contains() instead of manual checking. Place if statements before
for loops to skip over useless loops.