you could avoid this loop by counting collections in the previous one