also could likely express this more clearly as a foldl.