Changed unnecessary loop to a conditional.