You don't need to loop this list four times, you can use type checking instead.