fixed endless loop