speed up for each loops by breaking on invalid pointer as it is filled sequentially