Allocate less memory by not using iterators