don't loop more than it is needed