rewrote loop using functions instead of a struct-like object.