minor loop optimization